package edu.sctu.zhoudie.mouth201506.day20150615;

import java.io.*;

/**
 * Created by user08 on 2015/6/15.
 * 
 * 从键盘读入字符串，并由屏幕输出
 */
public class PrintData {
    public void myPrintData(){
        int count;
        byte[] b = new byte[256];
        BufferedInputStream in = new BufferedInputStream(System.in);//输入缓冲区流对象
        BufferedOutputStream bout = new BufferedOutputStream(System.out);//输出缓冲区流对象
        DataOutputStream out = new DataOutputStream(bout);//输出流对象
        PrintStream p = new PrintStream(System.out); //输出流对象
        try {
            p.print("请输入字符串：");
            count = in.read(b);
            in.close();
            p.println("读入字符数：" + count);
            p.print("输入的字符串为：");
            out.write(b,0,count);
           bout.flush(); // 将缓冲区的数据输出到屏幕上
            p.close();
            out.close();
        } catch (IOException e) {
            System.out.println("发生IO错误！");
        }
    }
}
